// Copyright 2007-2010 Comdiv (F. Sadykov) - http://code.google.com/u/fagim.sadykov/
// Supported by Media Technology LTD 
//  
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//  
//      http://www.apache.org/licenses/LICENSE-2.0
//  
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// 
// MODIFICATIONS HAVE BEEN MADE TO THIS FILE
using System;
using Comdiv.Extensions;
using Comdiv.Logging;
using MvcContrib.Comdiv.Brail;

namespace Comdiv.Doc{
    public class RenderContentStep : DocumentProcessorStep<RenderContentStep>{
        private ILog log = logger.get<RenderContentStep>();
        protected override void internalProcess(DocumentQuery query){
            MyQuery = query;
            MyBrail brail;
            if (MyQuery.Context != null){
                brail = MyQuery.Context.Brail;
                if (brail.ViewDirectory.noContent()){
                    brail.ViewDirectory = query.ViewDirectory;
                }
            }
            else{
                brail = new MyBrail{ViewDirectory = MyQuery.ViewDirectory};
            }
            try{
                query.IndexPage = brail.ProcessView("index", new{query = MyQuery});
                log.Info("index page generated");
                foreach (var nsname in MyQuery.Types.Keys){
                    query.NamespacePages[nsname] = brail.ProcessView("ns",
                                                                     new{
                                                                            query = MyQuery,
                                                                            myns = nsname,
                                                                            types = MyQuery.Types[nsname]
                                                                        });
                    log.Info("namespace page for {0} generated", nsname);
                    foreach (var type in MyQuery.Types[nsname]){
                        type.DocumentPage = brail.ProcessView("type", new{query = MyQuery, mytype = type});
                        log.Info("type page for {0} generated", type.Type.FullName);
                        foreach (var info in type.GetMethods()){
                            
                        }
                        foreach (var info in type.GetMethods(true))
                        {
                            if(info.IsPrivate) continue;
                            var doc = type.GetDoc(info);                            
                        }
                        foreach (var info in type.GetProperties())
                        {

                        }
                        foreach (var info in type.GetProperties(false))
                        {

                        }

                    }
                }
            }catch(Exception ex){
                log.Error("error on processing ",ex);
                throw;
            }
            base.internalProcess(query);
        }
    }
}